GATE CSE 2017 SET-2


Q1.

Consider the following C Program. #include < stdio.h > #include < string.h > #int main ( ) { char* c = "GATECSIT2017"; char* p = c; printf("%d", (int) strlen (c+2[p]-6[p]-1)); return 0; } The output of the program is _______________.
GateOverflow

Q2.

Consider the following function implemented in C: void printxy (int x, int y) { int *ptr ; x = 0; ptr = &x y = * ptr; * ptr = l; print f ("%d, %d," x, y); } The output of invoking printxy (1,1) is
GateOverflow

Q3.

Consider the following snippet of a C program. Assume that swap (&x, &y) exchanges the contents of x and y. int main ( ) { int array[]={3,5,1,4,6,2}; int done =0 ; int i ; while (done = = 0) { done = 1; for (i = 0; i <=4; i ++) { if (array [i] < array [i +1]) { swap (& array [i], &array [i+1]); done = 0; } } for (i = 5 ; i > =1; i --) { if (array [i] > array [ i-1]) { swap ( & array [i] , &array [i-1]); done = 0; } } } printf ( " %d " , array [3] ); } The output of the program is ____________.
GateOverflow

Q4.

The pre-order transversal of a binary search tree is given by 12, 8, 6, 2, 7, 9, 10, 16, 15, 19, 17, 20. Then the post-order traversal of this tree is:
GateOverflow

Q5.

Consider the following C function int fun (int n) { int i, j; for (i = 1; i < = n; i++) { for (j = 1 ; j < n ; j+=i) { printf ("%d %d , i, j ) ; } } } Asymptotic Notation of fun in terms of \theta notation is
GateOverflow

Q6.

Match the algorithms with their time complexities:
GateOverflow

Q7.

In a two-level cache system, the access times of L_{1} and L_{2} caches are 1 and 8 clock cycles, respectively. The miss penalty from L2 cache to main memory is 18 clock cycles . The miss rate of L_{1} cache is twice that of L_{2}. The average memory access time (AMAT) of this cache system is 2 cycles. This miss rates of L_{1} and L_{2} respectively are :
GateOverflow

Q8.

Consider a machine with a byte addressable main memory of 2^{32} bytes divided into blocks of size 32 bytes. Assume that a direct mapped cache having 512 cache lines is used with this machine. The size of the tag field in bits is ______.
GateOverflow

Q9.

The read access times and the hit ratios for different caches in a memory hierarchy are as given below. The read access time of main memory is 90 nanoseconds. Assume that the caches use the referred word-first read policy and the write back policy. Assume that all the caches are direct mapped caches. Assume that the dirty bit is always 0 for all the blocks in the caches. In execution of a program, 60% of memory reads are for instruction fetch and 40% are for memory operand fetch. The average read access time in nanoseconds (up to 2 decimal places) is______.
GateOverflow

Q10.

If f(x)=R sin(\frac{\pi x}{2})+S,f'(\frac{1}{2})=\sqrt{2} and \int_{0}^{1}f(x)dx=\frac{2R}{\pi }, then the constants R and S are, respectively
GateOverflow